hysop.parameters.tensor_parameter module

class hysop.parameters.tensor_parameter.TensorParameter(name, shape, dtype=<class 'numpy.float64'>, pretty_name=None, initial_value=None, min_value=None, max_value=None, ignore_nans=False, **kwds)[source]

Bases: Parameter

A tensor parameter is np.ndarray of a given dtype and shape that may change value as simulation advances.

Initialize a TaggedObject with a tag prefix/postfix/formatter, all optional.

__getitem__(slices)[source]

Get a read-only subview on this array parameter.

static __new__(cls, name, shape, dtype=<class 'numpy.float64'>, pretty_name=None, initial_value=None, min_value=None, max_value=None, ignore_nans=False, **kwds)[source]

Create or get an existing TensorParameter with a specific name shape and dtype.

Parameters:
  • name (string) – A name for the parameter that uniquely identifies it.

  • pretty_name (string) – A pretty name for the parameter.

  • shape (array like of ints) – Shape of this TensorParameter.

  • dtype (type convertible to np.dtype, optional) – Underlying dtype of this TensorParameter. Defaults to HYSOP_REAL.

  • initial_value (optional, defaults to an uninitialized array.) – Initial value as a scalar or np.ndarray. If not initial value is given, all values initialized to 0.

  • min_value (scalar, optional, defaults to None) – Minimum value allowed for this parameter.

  • max_value (scalar, optional, defaults to None) – Maximum value allowed for this parameter.

  • ignore_nans (bool) – Set this to True to allow NaN values.

  • kwds (dict) – Base class arguments.

shape

Shape of this TensorParameter.

Type:

array like of ints

dtype

Underlying dtype of this TensorParameter.

Type:

type convertible to np.dtype

min_value

Minimum value allowed for this TensorParameter.

Type:

scalar, optional, defaults to None

max_value

Maximum value allowed for this TensorParameter.

Type:

scalar, optional, defaults to None

ignore_nans

True if this TensorParameter can have NaN values.

Type:

bool

__setitem__(slices, value)[source]

Set a subview on this array parameter to a certain value (value can be broadcasted).

check_values(a)[source]
property ctype

Get the data type of the discrete field as a C type.

property dtype

Get parameter dtype.

property ignore_nans

Return True if array can have NaNs.

iterviews()[source]

Iterate over all parameters views to yield scalarparameters.

long_description()[source]

Return a long description of this parameter as a string.

property max_value

Return maximum value allowed for array values.

property min_value

Return minimum value allowed for array values.

reallocate_tensor(shape, dtype, initial_value=None)[source]
property shape

Get parameter shape.

short_description()[source]

Return a short description of this parameter as a string.

property size

Get parameter size.

property tensor_value

Get a read-only view on this array parameter but always as a numpy array, even for ScalarParameter parameters.

view(idx, name=None, pretty_name=None, **kwds)[source]

Take a view on a scalar contained in the Parameter.